package com.jic.market.mapper;

import com.jic.market.entity.PatchGrouponTheme;
import com.jic.market.entity.PromotionEntity;
import com.jic.market.orm.BaseMapper;
import com.jic.market.entity.PatchGrouponThemeEntity;
import com.jic.market.orm.Pagination;
import com.jic.market.request.QueryPromotionListRequest;
import com.jic.market.response.PromotionResponse;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface PatchGrouponThemeEntityMapper extends BaseMapper<PatchGrouponThemeEntity>{


    /**
     * 根据list
     * @param ids
     * @return
     */
    List<PatchGrouponTheme> queryListByIds(@Param("deptId") Long deptId,
                                           @Param("deleteFlag") Integer deleteFlag,
                                           @Param("ids") List<Long> ids);


    /**
     * 查询模板数量
     * @param patchGrouponThemeEntity
     * @return
     */
    int countOfTemplate(PatchGrouponThemeEntity patchGrouponThemeEntity);


    List<PatchGrouponThemeEntity> findOfPageByDept(@Param("po") PatchGrouponThemeEntity var1, @Param("page") Pagination var2);

    int countOfPageByDept(@Param("po") PatchGrouponThemeEntity var1);

    /**
     * 提供与前端查询列表
     * @param var1
     * @param var2
     * @return
     */
    List<PatchGrouponThemeEntity> findOfPageForRest(@Param("po") PatchGrouponThemeEntity var1, @Param("page") Pagination var2);

    /**
     * 提供与前端查询列表数量
     * @param var1
     * @return
     */
    long countOfPageForRest(@Param("po") PatchGrouponThemeEntity var1);

    List<PromotionResponse> queryPromotionList(@Param("po") QueryPromotionListRequest request);

    Long queryPromotionListCount(@Param("po") QueryPromotionListRequest request);

    @Select("select * from patch_groupon_theme where end_time >= #{startTime} and end_time < #{endTime} and status = 11 and now() > end_time")
    List<PatchGrouponThemeEntity> queryEnd(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
